package com.cefa.finance.utils;

import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.Map;

public class BeanUtils {

    public static Map bean2Map(Object obj) {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.convertValue(obj, Map.class);
    }

    public static <T> T map2Bean(Map fromValue, Class<T> toValueType) throws IllegalArgumentException {
        ObjectMapper objectMapper = new ObjectMapper();
        return objectMapper.convertValue(fromValue, toValueType);
    }
}
